1. Technology Field
The present invention relates to a wear leveling method. More particularly, the present invention relates to a wear leveling method for a flash memory, a storage system and a controller using the same.
2. Description of Related Art
With a quick developing of digital camera, cell phone camera and MP3, demand of storage media by customers is increased greatly. Since a flash memory has the advantages of non-volatile, energy saving, small size and none mechanical structure etc., it is suitable for portable applications, and especially for portable battery-powered products. A memory card is a storage device applying an NAND flash memory as the storage media. Since the memory card has a small size and a large volume, and is easy to be carried, it has been widely used for storing important personal data. Therefore, the flash drive industry becomes a hot industry within the electronics industry recently.
Generally, the flash memory of a flash memory storage system is divided into a plurality of physical blocks, and the physical blocks are grouped into a data area and a spare area. The physical blocks grouped in the data area are used for storing valid data written based on writing commands, and the physical blocks of the spare area are used for replacing the physical blocks in the data area while executing the writing command. To be specific, when the flash memory storage system receives the writing command from a host for writing data in the physical block of the data area, the flash memory storage system selects a physical block from the spare area, and writes old valid data stored in the physical block of the data area to be written and new data into the physical block selected from the spare area, and further associates the physical block written with the new data to the data area. Moreover, the original physical block in the data area is erased and is associated to the spare area. To smoothly access the physical blocks storing data in an alternation approach, the flash memory storage system can provide logical blocks to the host. Namely, alternation of the physical blocks is reflected by recording and renewing a mapping relation between the logical blocks and the physical blocks of the data area within a logical-physical mapping table, so that the host can only perform writing to the provided logical blocks, and the flash memory storage system then can read data from or write data into the mapped physical blocks according to the logical-physical mapping table.
However, erase times of the physical block is limited (for example, the memory blocks may be worn after ten thousand times of erase). If a physical block is only programmed for once, and none programming is performed afterwards, wearing of the block is relatively low. Conversely, if the physical block is repeatedly programmed and erased, wearing of the physical block is relatively high. Therefore, the so-called wearing is number of times that each of the physical blocks is programmed or erased.
When a physical block is damaged due to excessive high wearing extent thereof, the damaged physical block is then put into a bad block area and is no longer used again. Particularly, when a number of the damaged physical blocks is greater than a threshold value, and the undamaged physical blocks are not sufficient for storing data, even if there are still other unworn physical blocks, the flash memory storage system is still judged to be useless. However, some data stored in the storage system may keep unchanged for a long time, for example, after a user stores favourite music files within the storage system, the music files may keep unchanged for a long time. Therefore, wearing extents of different physical blocks can be greatly different.
Accordingly, a wear leveling method is required to effectively prolong a lifespan of the flash memory storage system.